#!/bin/sh

basedir=`dirname $0`
basedir=`cd $basedir;pwd`

cd -P ${basedir}

export PYTHONHOME=${basedir}
export PYTHONPATH=${basedir}/local/lib/python3.6/:${basedir}/local/lib/python3.6/lib-dynload/:${basedir}/local/lib/python3.6/site-packages/:${basedir}/local/lib64/python3.6/site-packages/
export LD_LIBRARY_PATH=${basedir}/local/lib64:${basedir}/lib:$LD_LIBRARY_PATH

${basedir}/local/bin/python3m - $@ <<EOF
# -*- coding: utf-8 -*-
import re
import sys

try:
    from pip import main
except ImportError:
    # user has most probably upgraded pip in their home
    # so let them run it anyway until ~/.local/bin makes it in front of the PATH
    from pip._internal import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())
EOF
